package com.atguigu.gmall;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class ActivityApp {

    public static void main(String[] args) {
        SpringApplication.run(ActivityApp.class, args);
    }


    /**
     * Caffine本地缓存应用
     * @return
     */
    @Bean
    public Cache<String, String> seckillCache(){
        Cache<String, String> cache = Caffeine.newBuilder()
                .initialCapacity(0)  //初始化容量
                .maximumSize(3)  //缓存最大数量
                //.expireAfterWrite(1, TimeUnit.DAYS)  //设置有效期
                .build();
        return cache;
    }

}
